package me.shurufa.activities;

import android.os.Bundle;
import android.support.v4.app.FragmentTransaction;
import android.text.TextUtils;

import com.google.gson.Gson;

import me.shurufa.R;
import me.shurufa.fragments.BookCommentAllFragment;
import me.shurufa.model.BookInfo;
import me.shurufa.utils.Constants;

/**
 * 点击图书->点击查看全部评价跳转的页面
 * 通过bookId获取全部评价
 *
 * @FileName: me.shurufa.activities.BookCommentActivity.java
 * @author: kHRYSTAL
 * @email: 723526676@qq.com
 * @date: 2016-02-02 15:15
 */
public class BookCommentActivity extends BaseActivity{


    private String bookTitle;
    private long bookId;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        activity_layout_res = R.layout.activity_book_comment;
        super.onCreate(savedInstanceState);
        bookId = getIntent().getLongExtra(Constants.ARG_BOOK_ID,0L);
        if (bookId == 0L)
            return;

        bookTitle = getIntent().getStringExtra(Constants.ARG_BOOK_TITLE);
        uiInit();
        initData();
    }

    private void initData() {
        BookCommentAllFragment fragment = BookCommentAllFragment.newInstance(bookId);
        FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
        transaction.add(R.id.fragment_container,fragment);
        transaction.commit();
    }

    private void uiInit() {
        if (!TextUtils.isEmpty(bookTitle)){
            titleTextView.setText(bookTitle);
        }
    }




}
